<template>
	<view>
		<view class="">
			<view class="login">
				<view>
					<view class="tu">
						<u--input :placeholder="$t('repwd.oldpwd')" type="password" v-model="oldpwd"></u--input>
					</view>
					<view class="tu" style="margin-top: 20px;">
						<u--input :placeholder="$t('repwd.newpwd')" type="password" v-model="newpwd"></u--input>
					</view>
					<view class="tu" style="margin-top: 20px;">
						<u--input :placeholder="$t('repwd.newrepwd')" type="password" v-model="newrepwd"></u--input>
					</view>
					<u-button type="defalut"  :text="$t('app.qd')" color="#014099" style="margin-top: 30px; " @click="updatepwd()"></u-button>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
		import { getResponseData, showToastTip,getBaseUrl,getWsUrl} from "@/api/req.js";
	export default {
		data() {
			return {
               oldpwd:'',
			   newpwd:'',
			   newrepwd:''
			   
			   
			}
		},
		methods: {
              updatepwd(){
				  if(this.oldpwd==""){
					  uni.showToast({
					  	title: this.$t('repwd.oldpwd'),
					  	icon: 'none',
					  	duration: 2000
					  })
					  return;
				  }
				  if(this.newpwd==""){
				  					  uni.showToast({
				  					  	title: this.$t('repwd.newpwd'),
				  					  	icon: 'none',
				  					  	duration: 2000
				  					  })
				  					  return;
				  }
				  if(this.newrepwd==""){
				  					  uni.showToast({
				  					  	title: this.$t('repwd.newrepwd'),
				  					  	icon: 'none',
				  					  	duration: 2000
				  					  })
				  					  return;
				  }
				  if(this.newpwd!=this.newrepwd){
				  					  uni.showToast({
				  					  	title: this.$t('repwd.panduan'),
				  					  	icon: 'none',
				  					  	duration: 2000
				  					  })
				  					  return;
				  }
				  
				  var that = this;
				  getResponseData("/userInfo/updPassword", 'get',{
					  password:this.oldpwd,
					  newPassword:this.newpwd
				  }, function(res) {
				  	uni.showToast({
							title: res.msg,
							icon: 'none',
							duration: 2000
						})
				  	if (res.code == 200) {
						uni.setStorageSync('token','');
						uni.navigateTo({
							url: '../index/test'
						})
				  	}
				  })
			  }
		}
	}
</script>

<style>
	page{
		background-color: #F0F0F0;
	}
	.tu {
		width: 475rpx;
		background-color: white;
	}

	.login {
		margin-top: 60px;
		display: flex;
		justify-content: center;
	}
</style>